package com.qujia.enums;

/**
 * 积分消费类型
 */
public enum RecordTypeEnum {
    INCREASE("1", "+", "增加积分"),
    DECREASE("2", "-", "减少积分");

    private String code;
    private String name;
    private String desc;

    RecordTypeEnum(String code, String name, String desc) {
        this.code = code;
        this.name = name;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public static String getNameByCode(String code) {
        for (RecordTypeEnum type : RecordTypeEnum.values()) {
            if (type.getCode().equals(code)) {
                return type.getName();
            }
        }
        throw new IllegalStateException("enums.type.invalidcode#" + code + "#"
                + RecordTypeEnum.class.getName());
    }
}
